define(
	[
		'require'
	],
	function(require){
		var EmSet = Ember.set;
		var Controller = Ember.Controller.extend({
			pcapsList: Ember.A([{name: "加载中..."}]),

			requireData: function(type){
				var ctrl = this;

				ctrl.set("pcapsList", Ember.A([{name: "加载中..."}]));
				ctrl.store.ajax("GET", "pcaps")
				.then(function(response){
					Ember.A(response.result).forEach(function(item){
						item._displayCreateTime = APM.util.formatDate(item.createTime, "F");
						item.url = ADAPTER_URL + "/pcaps/download/"+item.name+"?token="+encodeURIComponent($.cookie("token"));
					});
					ctrl.set("pcapsList", response.result);
				});
			},

			actions: {
				remove: function(pcap){
					var ctrl = this;

					this.store.ajax("DELETE", "pcaps/"+pcap.id)
					.then(function(response){
						ctrl.get("pcapsList").removeObject(pcap);
					});
				}
			}
		});

		APM.ConfigPcapController = Controller;
		return Controller;
	}
);